<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="btn">显示当前系统时间</button>
    <button id="btn2">显示当前系统时间2</button>
    <div id="time">某个时间</div>
    <div id = time2> 某个时间2</div>
    
    <script>
        // 获取元素对象
        var btn = document.getElementById("btn");
        var time = document.querySelector("#time");
        
        // 注册事件
      btn.onclick = function(){
        // 获取当前系统时间
        var now = new Date();
        // 格式化时间
        var year = now.getFullYear();
        var month = now.getMonth() + 1;
        var date = now.getDate();
        var hour = now.getHours();
        var minute = now.getMinutes();
        var second = now.getSeconds();
        var strTime = year + "年" + month + "月" + date + "日 " + hour + "时" + minute + "分" + second + "秒";
        // 修改元素文本
        time.innerText = strTime;
        }
        btn2.onclick = function(){
            // 获取当前系统时间
        var now = new Date();
        // 格式化时间
        time2.innerText = now.toLocaleString();
        }

    </script>

</body>
</html>